home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / mbase1.zip / MBASE.DOC next >
Text File  |  1992-12-16  |  34KB  |  1,036 lines

  1.  
  2.  
  3.  
  4.                        Mbase5 v2.60
  5.             The City, State, Zip Clipper Library
  6.  
  7.                 Written by Thomas D. Stubbs
  8.             All programs and documentation are
  9.       Copyright 1992 by MAILbase.  All rights reserved.
  10.  
  11.                           MAILbase
  12.                 3074 Lancaster Dr NE Ste 222
  13.                     Salem, OR 97305-1349
  14.                        (503) 393-1564
  15.  
  16.  
  17.  
  18.  
  19.                          - LICENSE -
  20.  
  21. MAILbase grants the purchaser a license to use this software
  22. on one computer system.  The right to use this program can be
  23. transfered to another user, on a different computer system, as
  24. long as the program is never used on two different computer
  25. systems at the same time.  If two systems use this program
  26. at the same time it is a violation of this license.  MAILbase
  27. authorizes you to make copies of this program as long as the
  28. copies are only used for backing up the original diskettes in
  29. the event they are destroyed. MAILbase grants you the right
  30. to use, give away, or sell all programs that you write, and
  31. compile with this product, however, due to an existing
  32. licensing agreement with the United States Postal Service,
  33. A LICENSING FEE IS REQUIRED if multiple copies of the City,
  34. State, Zip datafile are to distributed by the purchaser of
  35. this software.
  36.  
  37.  
  38.  
  39.                 *** DISCLAIMER OF WARRANTY ***
  40.  
  41. THESE PROGRAMS ARE PROVIDED ON AN AS-IS BASIS. MAILBASE MAKES
  42. NO WARRANTY, EXPRESS OR IMPLIED, AS TO PERFORMANCE, MERCHANT-
  43. ABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL
  44. MAILBASE BE HELD LIABLE FOR ANY DAMAGES, INCLUDING BUT NOT
  45. LIMITED TO LOSS OF USE, LOST REVENUE, SPECIAL, CONSEQUENTIAL,
  46. INDIRECT OR SIMILAR DAMAGES, EVEN IF MAILBASE OR AN AGENT OF
  47. MAILBASE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
  48. IN NO EVENT SHALL MAILBASE LIABILITY FOR ANY DAMAGES EVER
  49. EXCEED THE PRICE PAID FOR THE SOFTWARE, REGARDLESS OF THE
  50. FORM OF THE CLAIM.
  51.  
  52.  
  53.  
  54.  
  55.  
  56. Overview:
  57.  
  58.    The MAILBASE.CSZ file is an optimally compressed file that
  59. contains all City, State, and Zip Codes currently recognized
  60. by the United States Postal Service.  This data is cross-
  61. referenced in several ways to allow a developer to create an
  62. interactive enviroment that makes data entry faster and more
  63. accurate.  The functions provided simplify the development
  64. of this enviroment, since all file handling, indexing,
  65. filtering, and searching is built in.  Additionally, the
  66. MAILBASE.CSZ file stands alone.  There are no other files
  67. used or created, making the application more transportable
  68. since the MAILBASE.CSZ file is only about 800K (compare this
  69. to using DBF's and NTX's which would require 5 to 10 times
  70. as much disk space).
  71.  
  72.    The data contained in MAILBASE.CSZ is much more in depth
  73. than merely the City, State, and Zip Codes.  Each data type,
  74. is assigned a TYPE CODE which the developer can interpret
  75. for further cross referencing.  The city names included not
  76. only have the USPS recognized preferred names, but also
  77. approved abbreviations and local community names comprising
  78. over 80,000 city names.  The type codes for the city will
  79. tell the delevoper if an alternate name is available or
  80. preferred and if an abbreviation exists.  (All approved
  81. city names longer than 13 characters have a corresponding
  82. approved abbreviation).  States are categorized by US state,
  83. territory, or Military PO.  Zip codes are identified as
  84. general/residential, PO Boxes Only, Unique to a single
  85. company or government office, or APO/FPO.
  86.  
  87.    The MAILBASE.CSZ file contains the most current
  88. information available from the United States Postal
  89. Service.  Updates are available the second month of
  90. each quarter, (FEBRUARY, MAY, JULY, & NOVEMBER).
  91.  
  92.  
  93.  
  94.  
  95. About City Types:
  96.  
  97.    There are currently 9 city types defined.  The numbers
  98. used are spaced to allow room for future development with
  99. little or no upgrade shock.  Frequently a Zip Code will
  100. have more than one valid City Name.  In this library these
  101. City Names are assigned a level of precedence.  The most
  102. common city name for a given zip code is called the
  103. 'Dominant' city name.  This does not necessarily mean it
  104. is more correct than the city name inputed.  However, if
  105. the dominant name is used, the Post Office will still be
  106. able to deliver it.  If a zip code has more than one city
  107. name, this means that each city is valid for that zip.
  108. The dominant is the city that uses most of that zip code.
  109. Note that the city type is specific to a particular
  110. city and zip combination.  It would not be correct to
  111. assume that a type code for a city in one zip code would
  112. be the same as that in the next zip code.  If the returned
  113. city type is greater than 1, then that zip code will have
  114. alternative names available.  In the case of the city type
  115. equal to 6 or 7 there will be two alternative city names.
  116. The alternate names are returned by using the CITYAKA()
  117. function.
  118.  
  119.     type  1: Dominant City Name, no alternates available)
  120.     type  2: Abbreviation of a Dominant, alternate will
  121.              be the full city name.
  122.     type  3: Dominant that has an abbreviation, alternate
  123.              will be abbreviation.
  124.     type  4: City name that has equal alternate (neither
  125.              is more dominate than the other), alternate
  126.              will be the other.
  127.     type  5: Non-dominate city name, alternate will be
  128.              the dominate city name.
  129.     type  6: Abbreviation of a non-dominant (has 2
  130.              alternates), alternate 1 will be the
  131.              unabbreviation of the non-dominate,
  132.              alternate 2 will be the dominate city name.
  133.     type  7: Non-dominant that has an Abbreviation (has
  134.              2 alternates), alternate 1 will be the
  135.              abbreviation of the non-dominate,
  136.              alternate 2 will be the dominate city name
  137.     type 17: Abbreviation or a non-dominant, this is
  138.              both an approved abbreviation as well as
  139.              a locally known name.  Alternate will be
  140.              the dominate city name.
  141.     type 32: This is a locally known name, however it
  142.              is not an approved USPS name.  You should
  143.              use its alternate which will be the
  144.              dominate city name.
  145.  
  146. Large cities will have numerous unapproved names (type 32).
  147. One of the advantages about non-dominant or unapproved
  148. names is that they help narrow down the exact zip code
  149. for a dominate zip name.  For example Eola, Oregon is
  150. an unapproved city name.  The correct city to use is
  151. Salem, Oregon, however, Salem uses Zipcodes 97301-97314.
  152. Eola is specifically 97304, therefor the proper
  153. alternative would be Salem, OR 97304.
  154.  
  155.  
  156.  
  157.  
  158. About State Types:
  159.  
  160. There are only 3 types of states currently defined.  The
  161. most common are the 51 US states (includes DC).  There
  162. are 3 abbreviation assigned to APO's and FPO's (AA, AE
  163. and AP).  The other type are the US territories or
  164. non-US states that have been assigned an abbreviation.
  165. Appendix B lists all of the abbreviations currently
  166. assigned by the USPS.
  167.  
  168.     type 1: US State
  169.     type 2: US territory or non-US state
  170.     type 3: APO/FPO's
  171.  
  172.  
  173.  
  174.  
  175. About Zip Types:
  176.  
  177. There are 4 Zip types.  The most common are the general/
  178. residential zip codes.  Additionally, some zip codes are
  179. used for PO Boxes only.  If the street address is not
  180. a PO Box but the zip code is identified as a PO Box only
  181. then the wrong zip code is being used.  Some zip codes
  182. are unique to large company, organization, or government
  183. offices.  If a residential street address has one of
  184. these zip codes, the wrong zip code is being used.
  185. Lastly, there are several zip codes assigned to APO's
  186. and FPO's (military overseas Post Offices).
  187.  
  188.     type 1: general/residential
  189.     type 2: PO Box Only
  190.     type 3: Unique
  191.     type 4: APO/FPO's
  192.  
  193.  
  194.  
  195.  
  196.  
  197.                - DOCUMENTATION STANDARDS -
  198.  
  199.  
  200. Required parameters are shown enclosed with <> and optional
  201. parameters with [].
  202.  
  203. Parameters are usually descriptive and will always be shown
  204. lowercase with the first character upper case, indicating
  205. its data type (i.e. C-Character, L-logical, N-numeric, A-array).
  206.  
  207. Functions are usually displayed and referred to in upper case.
  208. However if you are compiling with case sensitivity ON, you
  209. should use them exactly as displayed in the Syntax and
  210. Example (mixed case).
  211.  
  212.  
  213.  
  214.     CITY2ZIP()
  215.     ──────────────────────────────────────────────────────────
  216.     Syntax: City2Zip(<Ccity>,[Azip],[Actype],[Aztype],;
  217.                      [Csfilter],[Lcfilter],[Nzfilter])
  218.  
  219.  
  220.     Use:  To determine the existence of a city name and
  221.           fill arrays for zipcode, city type code, and
  222.           zip type code.
  223.  
  224.  
  225.     Arguments:
  226.  
  227.         <Ccity>    is the city name character string to be
  228.                    searched for.
  229.  
  230.         [Azip]     is the array to be filled with zip codes
  231.                    valid for the city name (listed in
  232.                    ascending order).
  233.  
  234.         [Actype]   is the array to be filled with city type
  235.                    code corresponding to each zip.  (see
  236.                    discussion on city types and table 1).
  237.  
  238.         [Aztype]   is the array to be filled with zip type
  239.                    code corresponding to each zip.  (see
  240.                    discussion on zip types and table 2).
  241.  
  242.         [Csfilter] is a USPS approved two letter state
  243.                    abbreviation.  If included only those
  244.                    zipcodes for this state will be found.
  245.  
  246.         [Lcfilter] is a logical to exclude zipcodes for
  247.                    which the city is not a preferred name.
  248.                    (set .T. to exclude).
  249.  
  250.         [Nzfilter] is a binary encoded numeric for the zip
  251.                    types 1-4.  If specified, only those zips
  252.                    of this type will be found. Default is
  253.                    0 (see table 3)
  254.  
  255.  
  256.     Return Value of the Function:  Numeric, the total number
  257.         of elements meeting the search criteria regardless of
  258.         array size.  Arrays will only be filled up to this
  259.         value or the maximum declared array size.
  260.  
  261.  
  262.     Error Determination:  If the return value is 0, the city
  263.         name was not found.  Values less than 0 indicate an
  264.         error.  Call MbaseErr() to determine nature of the
  265.         error.
  266.  
  267.  
  268.     Discussion:  This function is ideal for creating a pick
  269.         list of zip codes or checking if an existing zip
  270.         code and city combination is valid.  In operation,
  271.         the first time a city is seeked, there will be a
  272.         potentially noticable delay, depending upon the
  273.         number of zip codes involved.  Because seeking a
  274.         city name is the slowest operation in this library,
  275.         the last city seeked remains in memory so repeated
  276.         seeks of the same city will be much faster.  The
  277.         filters will reduce the total number of zip codes
  278.         returned.  There is no case sensitivity or trimming
  279.         needed for the city and state parameters.
  280.            It is also possible to determine the city
  281.         state and zip for some universities, large
  282.         businesses, and government agencies.  Several
  283.         have been included among the list of cities and will
  284.         usually return a city type of 32.  Given the
  285.         returned zip you could then determine the
  286.         proper city etc.  Try 'Readers Digest' for
  287.         example.
  288.  
  289.  
  290.  
  291.            table 1:  City Types
  292.          ┌─────┬───────────────────────────────────────┐
  293.          │type │  meaning                              │
  294.          ├─────┼───────────────────────────────────────┤
  295.          │  1  │ Dominant City Name                    │
  296.          │  2  │ Abbreviation of a Dominant            │
  297.          │  3  │ Dominant that has an abbreviation     │
  298.          │  4  │ City name that has equal alternate    │
  299.          │  5  │ Non-dominate city name                │
  300.          │  6  │ Abbreviation of a non-dominant        │
  301.          │  7  │ Non-dominant that has an Abbreviation │
  302.          │ 17  │ Abbreviation or a non-dominant        │
  303.          │ 32  │ Unapproved name (should be replaced)  │
  304.          └─────┴───────────────────────────────────────┘
  305.  
  306.  
  307.            table 2:  Zip Types
  308.          ┌─────┬──────────────────────┐
  309.          │type │  meaning             │
  310.          ├─────┼──────────────────────┤
  311.          │  1  │ general/residential  │
  312.          │  2  │ PO Box Only          │
  313.          │  3  │ Unique               │
  314.          │  4  │ APO/FPO's            │
  315.          └─────┴──────────────────────┘
  316.  
  317.  
  318.            table 3:  Zip filter values
  319.          ┌──────┬─────────────────────────────┐
  320.          │value │  action                     │
  321.          ├──────┼─────────────────────────────┤
  322.          │  1   │ include general/residential │
  323.          │  2   │ include PO Box Only         │
  324.          │  4   │ include Unique              │
  325.          │  8   │ include APO/FPO's           │
  326.          ├──────┴─────────────────────────────┤
  327.          │ The sum of these values establish  │
  328.          │ the Nzfilter.  Nzfilter=0 includes │
  329.          │ all (same as Nzfilter=15).         │
  330.          └────────────────────────────────────┘
  331.  
  332.  
  333.     Examples:
  334.  
  335.         city="SALEM"
  336.         state="OR"
  337.  
  338.         City2Zip(city)                        && returns 58
  339.         City2Zip(city,"","","",state)         && returns 14
  340.         City2Zip(city,"","","",state,.T.)     && returns 14
  341.         City2Zip(city,"","","",state,,.T.,3)  && returns  9
  342.         City2Zip(city,"","","",state,.T.,1)   && returns  6
  343.  
  344.  
  345.  
  346.  
  347.  
  348.     CITYAKA()
  349.     ──────────────────────────────────────────────────────────
  350.     Syntax:  CityAKA(<Ccity>,<Czip>,<Nindex>)
  351.  
  352.     Use:  To retrieve other acceptable names or abbreviations
  353.           that the city with the given zip may also be known
  354.           as.
  355.  
  356.  
  357.     Arguments:
  358.  
  359.         <Ccity>    is the city name character string to be
  360.                    searched for.
  361.  
  362.         <Czip>     is the zip code that must exist for the
  363.                    given city to determine the AKA.
  364.  
  365.         <Nindex>   is the number of the AKA to return for
  366.                    city/zips that have more than one AKA.
  367.                    Currently this number is either 1 or 2.
  368.  
  369.  
  370.     Return Value of the Function:  Character string.
  371.  
  372.  
  373.     Error Determination:  Null string is returned if the Zip
  374.         does not exist for this city, no AKA exists or
  375.         <Nindex> is greater than the number of AKAs available.
  376.         MbaseErr() will be 0 for any of these cases.
  377.         MbaseErr() will be non zero in the event of an error.
  378.  
  379.  
  380.     Discussion:  This function retrieves the alternate names
  381.         for city and zip combinations that have a city type
  382.         greater than 1.  For city types 32 you should call
  383.         this function to get the correct city name.  All
  384.         other alternatives are essentially optional.  For
  385.         long city names (length > 13) an abbreviation will
  386.         be available.  It is conceivable that your database
  387.         structure could have city field length equal to 13
  388.         since there will always be an abbreviation less than
  389.         14 characters long.  This function will also convert
  390.         the abbreviation back to the full city name.  In
  391.         the case of non-dominant cities,  this function could
  392.         also reveal other cities that may be near it, even
  393.         if you choose not to use the dominant city name.
  394.  
  395.  
  396.     Example:
  397.  
  398.         DECLARE ziparray[10],typearry[10]
  399.         city="EOLA"
  400.         state="OR"
  401.  
  402.         retval=City2Zip(city,ziparray,typearry,"",state)
  403.  
  404.            && returns a value of 1
  405.            && typearry[1] = 32
  406.            && should replace city with:
  407.  
  408.         repcity=CityAKA(city,ziparray[1],1)
  409.  
  410.            && returns SALEM
  411.  
  412.  
  413.  
  414.      CITYTYPE()
  415.     ──────────────────────────────────────────────────────────
  416.     Syntax:  CityType(<Ccity>,<Czip>)
  417.  
  418.  
  419.     Use:  To determine the city type code for the given city
  420.           and zip.
  421.  
  422.  
  423.     Arguments:
  424.  
  425.         <Ccity>    is the city name character string to be
  426.                    searched for.
  427.  
  428.         <Czip>     is the zip code that must exist for the
  429.                    given city to determine type code.
  430.  
  431.  
  432.     Return Value of the Function:  Numeric
  433.  
  434.  
  435.     Error Determination:  Return value will be zero if
  436.         the city does not exist or if the zip does not exist
  437.         within that city.  A negative number is returned if
  438.         an error occurs.  Use MbaseErr() to determine the
  439.         cause of the error.
  440.  
  441.  
  442.     Discussion:  This function gives a quick way to determine
  443.         a city type without have to use the City2Zip() function
  444.         and handling the arrays.  With this function the
  445.         developer could take a given city and zip, then
  446.         determine whether or not the city is valid, or has
  447.         a possible alternate.
  448.  
  449.  
  450.     Example:
  451.  
  452.         city= "EOLA"
  453.         zip = "97304"
  454.  
  455.         retval=CityType(city,state)
  456.  
  457.         do case
  458.  
  459.            case retval=0
  460.               ? "         *** error ***           "
  461.               ? "this city does not exist or this "
  462.               ? "zip code is invalid for this city"
  463.  
  464.            case retval=32
  465.               ? "       *** warning ***
  466.               ? "this city is not USPS approved"
  467.               ? "it should be replaced with... "
  468.               ? CityAKA(city,zip,1)
  469.  
  470.            case retval>1
  471.               ? "       *** notice ***          "
  472.               ? "alternative city names are also"
  473.               ? "valid for this city & zip code "
  474.  
  475.         endcase
  476.  
  477.  
  478.  
  479.  
  480.     CLOSEMBASE()
  481.     ──────────────────────────────────────────────────────────
  482.     Syntax:  CloseMbase()
  483.  
  484.  
  485.     Use:  To close the datafile and free allocated memory.
  486.  
  487.  
  488.     Arguments:  none
  489.  
  490.  
  491.     Return Value of the Function:  none
  492.  
  493.  
  494.     Error Determination:  N/A
  495.  
  496.  
  497.     Discussion:  When the MAILBASE.CSZ file is opened one
  498.     file handle is used and 1-2K of memory is allocated
  499.     from the heap.  If you need to deallocate this memory,
  500.     free up a file handle, or resolve some sharing
  501.     problem this function is available.
  502.  
  503.  
  504.  
  505.  
  506.     FILLSTATE()
  507.     ──────────────────────────────────────────────────────────
  508.     Syntax:  FillState(<Cstate>,[Nfilter])
  509.  
  510.     Use:  To fill an array with all current USPS approved
  511.     state abbreviations.
  512.  
  513.     Arguments:
  514.  
  515.         <Cstate>  is a USPS approved two letter state
  516.                   abbreviation.
  517.  
  518.         [Nfilter] is a binary encoded numeric for the
  519.                   state types to return.  The default
  520.                   is 7 (all types).   [see table 4]
  521.  
  522.  
  523.     Return Value of the Function:  Numeric (Number of
  524.         elements meeting the filter criteria regardless
  525.         of declared array size).
  526.  
  527.  
  528.     Error Determination:  A negative number is returned
  529.         if an error occurs.  Use MbaseErr() to determine
  530.         the cause of the error.
  531.  
  532.  
  533.             table 4:
  534.           ┌───────┬─────────────────────────┐
  535.           │ value │   meaning               │
  536.           ├───────┼─────────────────────────┤
  537.           │   1   │ include US states       │
  538.           │   2   │ include US territories  │
  539.           │   4   │ include APO/FPO's       │
  540.           ├───────┴─────────────────────────┤
  541.           │ the sum of these values         │
  542.           │ establishes the filter criteria │
  543.           └─────────────────────────────────┘
  544.  
  545.  
  546.     Discussion:  Because the potential exists that more
  547.         states (most likely territories or Pacific Islands)
  548.         will be assigned abbreviations in the future, it
  549.         may be safer for a developer to use this function
  550.         rather than hard coding the abbreviations.  Any
  551.         changes will be contained within the updated
  552.         MAILBASE.CSZ file, thus no recompile is needed.
  553.         Plus it simply gives the developer an easy way
  554.         of creating a pick list or table of states.
  555.  
  556.  
  557.  
  558.  
  559.     ISSTATE()
  560.     ──────────────────────────────────────────────────────────
  561.     Syntax:  IsState(<Cstate>)
  562.  
  563.  
  564.     Use:  To determine if a two character abbreviation is an
  565.     approved USPS approved abbreviation for a US state.
  566.  
  567.  
  568.     Arguments:
  569.  
  570.          <Cstate> is a USPS approved two letter state
  571.                   abbreviation.
  572.  
  573.  
  574.     Return Value of the Function:  logical
  575.  
  576.  
  577.     Error Determination:  .F. is returned if either the input
  578.         is not a valid state abbreviation or if an error
  579.         occurs.  Use MbaseErr() to determine the if/what
  580.         caused the error.
  581.  
  582.  
  583.     Discussion:  Ideal function for a VALID function on
  584.         a GET.  See example.
  585.  
  586.  
  587.     Example:
  588.  
  589.         state="  "
  590.  
  591.         @ 10,30 SAY "Enter your state:" GET state VALID (IsState(state))
  592.         READ
  593.  
  594.  
  595.  
  596.  
  597.  
  598.     MBASEERR()
  599.     ──────────────────────────────────────────────────────────
  600.     Syntax:  MbaseErr()
  601.  
  602.  
  603.     Use:  To determine if and/or cause of an error created by
  604.     the last executed Mbase function.
  605.  
  606.  
  607.     Arguments:  none
  608.  
  609.  
  610.     Return Value of the Function:  numeric
  611.  
  612.  
  613.     Error Determination:  N/A
  614.  
  615.  
  616.           table 5:  error values
  617.         ┌─────┬──────────────────────────────────┐
  618.         │value│   meaning                        │
  619.         ├─────┼──────────────────────────────────┤
  620.         │  1  │ Error opening MAILBASE.CSZ file  │
  621.         │  2  │ Read error with MAILBASE.CSZ     │
  622.         │  3  │ Memory allocation error          │
  623.         └─────┴──────────────────────────────────┘
  624.  
  625.  
  626.  
  627.  
  628.  
  629.     OPENMBASE()
  630.     ──────────────────────────────────────────────────────────
  631.     Syntax:  OpenMbase([Cpath],[Lshared])
  632.  
  633.  
  634.     Use:  To open the MAILBASE.CSZ file and allocate
  635.           memory from the memory pool.
  636.  
  637.  
  638.     Arguments:
  639.  
  640.         [Cpath]   path to the MAILBASE.CSZ file.  If not
  641.                   specified, the default directory is
  642.                   used.
  643.  
  644.         [Lshared] if .T. the MAILBASE.CSZ file will be
  645.                   opened in shared mode.  You must have
  646.                   SHARE installed to do this.  Default
  647.                   is .F.
  648.  
  649.  
  650.     Return Value of the Function: Numeric
  651.  
  652.  
  653.     Error Determination:  Returns 0 if successful or
  654.         error code if unsuccessful.
  655.  
  656.  
  657.     Discussion:  This function allows the developer
  658.         to modify the path or open the MAILBASE.CSZ
  659.         file shared to suit the environment.
  660.         However, the file name cannot be modified.
  661.         Note: if you do not execute OpenMbase() prior
  662.         to executing one of the other functions.
  663.         OpenMbase() will be automatically executed
  664.         with its defaults.
  665.  
  666.     Example:
  667.  
  668.         if OpenMbase("\MYDIR",.T.) # 0
  669.  
  670.            ? "ERROR OPENING MAILBASE.CSZ FILE"
  671.  
  672.         endif
  673.  
  674.  
  675.  
  676.  
  677.  
  678.     STATEABBR()
  679.     ──────────────────────────────────────────────────────────
  680.     Syntax:  StateAbbr(<Cstatename>)
  681.  
  682.  
  683.     Use:  To determine the USPS approved abbreviation
  684.     for a given state.
  685.  
  686.  
  687.     Arguments:
  688.  
  689.          <Cstatename> Full name of a state.
  690.  
  691.  
  692.     Return Value of the Function: Character
  693.  
  694.  
  695.     Error Determination:  Returns Empty string if unsuccessful.
  696.         Use MbaseErr() to determine cause of the error.
  697.  
  698.  
  699.     Discussion:  If you are like me, some state abbreviations
  700.         don't seem quite so obvious.  For example,
  701.         Missouri-MO, Arizona-AZ, Alaska-AK.  It would be
  702.         very easy to mistakenly use MI,AR, or AL, which would
  703.         of course be valid abbreviations, but place you in
  704.         the wrong state.  In some enviroments it may be
  705.         safer to have the user type in the statename, or
  706.         select it from a pick list, then use this function
  707.         to insert the abbreviation.
  708.  
  709.  
  710.  
  711.  
  712.  
  713.     STATENAME()
  714.     ──────────────────────────────────────────────────────────
  715.     Syntax:  StateName(<Cstate>)
  716.  
  717.  
  718.     Use:  To determine the Full State Name for a
  719.     USPS approved abbreviation.
  720.  
  721.  
  722.     Arguments:
  723.  
  724.          <Cstate> is a USPS approved two letter state
  725.                   abbreviation.
  726.  
  727.  
  728.     Return Value of the Function: Character
  729.  
  730.  
  731.     Error Determination:  Returns Empty string unsuccessful.
  732.         Use MbaseErr() to determine cause of the error.
  733.  
  734.  
  735.     Discussion:  This could be a space saver for some
  736.         database structures where you want the user to
  737.         be very clear what state they are looking at.
  738.         If you had to allow enough room in your database
  739.         to handle the worst case; "Federated States of
  740.         Micronesia", alot of space is wasted on "OHIO".
  741.         Instead save "FM" or "OH" and call this function
  742.         when you display it to the user.
  743.  
  744.  
  745.  
  746.     ZIP2CITY()
  747.     ──────────────────────────────────────────────────────────
  748.     Syntax:  Zip2City(<Czip>,<Acity>,[Aztype])
  749.  
  750.     Use:  To fill an array with the acceptable city names
  751.           for a given zip code.
  752.  
  753.     Arguments:
  754.  
  755.         <Czip>     is the zip code to be searched for.
  756.  
  757.         <Acity>    is the array to be filled with possible
  758.                    names for this Zip.
  759.  
  760.         [Aztype]   is an array to fill with zip type codes
  761.                    corresponding to each city.
  762.  
  763.  
  764.     Return Value of the Function:  Numeric, the total number
  765.         of elements meeting the search criteria regardless of
  766.         array size.  Arrays will only be filled up to this
  767.         value or the maximum declared array size.
  768.  
  769.  
  770.     Error Determination:  If the return value is 0, the zip
  771.         code was not found.  Values less than 0 indicate an
  772.         error.  Call MbaseErr() to determine nature of the
  773.         error.
  774.  
  775.  
  776.     Discussion:  This is the real time saver for data entry.
  777.         Let the user enter the zip code first, then you can
  778.         provide a pick list of cities.  Along with the
  779.         Zip2State() function to fill in the state field.
  780.  
  781.  
  782.     Example:
  783.  
  784.         ZIP=SPACE(5)
  785.  
  786.         DO WHILE .T.
  787.  
  788.           @ 10,32 SAY "Enter your Zip Code:"
  789.           @ 11,38 GET ZIP
  790.           READ
  791.  
  792.           DECLARE CITIES[30],ZTYPE[30]
  793.           RET_VAL=Zip2City(ZIP,CITIES,ZTYPE)
  794.  
  795.           DO CASE
  796.             CASE RET_VAL>0
  797.               DISP_BOTTOM=IIF(RET_VAL>14,20,5+RET_VAL)
  798.               @ 2,39 TO DISP_BOTTOM,69 DOUBLE
  799.               CTY=ACHOICE(5,40,DISP_BOTTOM-1,68,CITIES,.T.)
  800.               REPLACE CITY WITH CITIES[CTY]
  801.               REPLACE STATE WITH Zip2State(ZIP)
  802.               EXIT
  803.  
  804.             CASE RET_VAL=0
  805.               @ 14,30 SAY "Invalid Zip, Please re-enter"
  806.  
  807.             CASE RET_VAL<0
  808.               ? "INTERNAL ERROR"
  809.  
  810.           ENDCASE
  811.  
  812.         ENDDO
  813.  
  814.  
  815.     ZIP2STATE
  816.     ──────────────────────────────────────────────────────────
  817.     Syntax:  Zip2State(<Czip>)
  818.  
  819.     Use:  To return the USPS approved two character
  820.           state abbreviation for a given Zip Code.
  821.  
  822.     Arguments:
  823.  
  824.         <Czip>     is the zip code to be searched for.
  825.  
  826.  
  827.     Return Value of the Function: Character
  828.  
  829.  
  830.     Error Determination:  Null is returned if an error
  831.         occurs.  This function will return a state regardless
  832.         of whether or not that Zip code has currently been
  833.         assigned by the USPS.
  834.  
  835.  
  836.     Discussion:  Do not rely on this function to
  837.         determine the validity of a zipcode.  Validity
  838.         is only detected by Zip2City() returning a
  839.         value greater than 0.  This function will always
  840.         return a state regardless of whether or not that
  841.         zip code has actually been assigned by the USPS.
  842.         To conserve disk space in most cases the state
  843.         is derived from the first 3 digits.  This function
  844.         does of course handle the exceptions to this rule
  845.         as well.
  846.  
  847.  
  848.  
  849.  
  850.     ZIPTYPE
  851.     ──────────────────────────────────────────────────────────
  852.     Syntax:  ZipType(<Czip>)
  853.  
  854.  
  855.     Use:  To determine the Zip type code for a given zip.
  856.  
  857.  
  858.     Arguments:
  859.  
  860.         <Czip>     is the zip code to be searched for.
  861.  
  862.  
  863.     Return Value of the Function:  Numeric
  864.  
  865.  
  866.     Error Determination:  0 is returned if the Zip code
  867.         does not exist, negative value indicates an error.
  868.         Use MbaseErr() to determine the cause of the error.
  869.  
  870.  
  871.     Discussion:  This is another way of getting the type
  872.         of address expected for a given zip code.  If the
  873.         street address is inconsistent with zip type then
  874.         zip code used is wrong.
  875.  
  876.  
  877.            table 2:  Zip Types
  878.          ┌─────┬──────────────────────┐
  879.          │type │  meaning             │
  880.          ├─────┼──────────────────────┤
  881.          │  1  │ general/residential  │
  882.          │  2  │ PO Box Only          │
  883.          │  3  │ Unique               │
  884.          │  4  │ APO/FPO's            │
  885.          └─────┴──────────────────────┘
  886.  
  887.  
  888.  
  889.  
  890.  
  891.  
  892.                         APPENDIX A
  893.                     SUMMARY OF TABLES
  894.  
  895.  
  896.  
  897.            table 1:  City Types
  898.          ┌─────┬───────────────────────────────────────┐
  899.          │type │  meaning                              │
  900.          ├─────┼───────────────────────────────────────┤
  901.          │  1  │ Dominant City Name                    │
  902.          │  2  │ Abbreviation of a Dominant            │
  903.          │  3  │ Dominant that has an abbreviation     │
  904.          │  4  │ City name that has equal alternate    │
  905.          │  5  │ Non-dominate city name                │
  906.          │  6  │ Abbreviation of a non-dominant        │
  907.          │  7  │ Non-dominant that has an Abbreviation │
  908.          │ 17  │ Abbreviation or a non-dominant        │
  909.          │ 32  │ Unapproved name (should be replaced)  │
  910.          └─────┴───────────────────────────────────────┘
  911.  
  912.  
  913.            table 2:  Zip Types
  914.          ┌─────┬──────────────────────┐
  915.          │type │  meaning             │
  916.          ├─────┼──────────────────────┤
  917.          │  1  │ general/residential  │
  918.          │  2  │ PO Box Only          │
  919.          │  3  │ Unique               │
  920.          │  4  │ APO/FPO's            │
  921.          └─────┴──────────────────────┘
  922.  
  923.  
  924.            table 3:  Zip filter values
  925.                      for Cty2Zip()
  926.          ┌──────┬─────────────────────────────┐
  927.          │value │  action                     │
  928.          ├──────┼─────────────────────────────┤
  929.          │  1   │ include general/residential │
  930.          │  2   │ include PO Box Only         │
  931.          │  4   │ include Unique              │
  932.          │  8   │ include APO/FPO's           │
  933.          ├──────┴─────────────────────────────┤
  934.          │ The sum of these values establish  │
  935.          │ the Nzfilter.  Nzfilter=0 includes │
  936.          │ all (same as Nzfilter=15).         │
  937.          └────────────────────────────────────┘
  938.  
  939.  
  940.            table 4:  State filter values
  941.                      for FillState()
  942.          ┌───────┬─────────────────────────┐
  943.          │ value │   meaning               │
  944.          ├───────┼─────────────────────────┤
  945.          │   1   │ include US states       │
  946.          │   2   │ include US territories  │
  947.          │   4   │ include APO/FPO's       │
  948.          ├───────┴─────────────────────────┤
  949.          │ the sum of these values         │
  950.          │ establishes the filter criteria │
  951.          └─────────────────────────────────┘
  952.  
  953.  
  954.            table 5:  error values
  955.                      for MbaseErr()
  956.          ┌─────┬──────────────────────────────────┐
  957.          │value│   meaning                        │
  958.          ├─────┼──────────────────────────────────┤
  959.          │  1  │ Error opening MAILBASE.CSZ file  │
  960.          │  2  │ Read error with MAILBASE.CSZ     │
  961.          │  3  │ Memory allocation error          │
  962.          └─────┴──────────────────────────────────┘
  963.  
  964.  
  965.  
  966.  
  967.  
  968.  
  969.                     APPENDIX B
  970.             LIST OF STATES & ABBREVIATIONS
  971.  
  972.  
  973.          AA - APO/FPO (MIAMI)
  974.          AE - APO/FPO (NEW YORK)
  975.          AP - FPO (SAN FRANCISCO)
  976.          AK - ALASKA
  977.          AL - ALABAMA
  978.          AR - ARKANSAS
  979.          AS - AMERICAN SAMOA
  980.          AZ - ARIZONA
  981.          CA - CALIFORNIA
  982.          CO - COLORADO
  983.          CT - CONNECTICUT
  984.          DC - DISTRICT OF COLUMBIA
  985.          DE - DELAWARE
  986.          FL - FLORIDA
  987.          FM - FEDERATED STATES OF MICRONESIA
  988.          GA - GEORGIA
  989.          GU - GUAM
  990.          HI - HAWAII
  991.          IA - INDIANA
  992.          ID - IDAHO
  993.          IL - ILLINOIS
  994.          IN - INDIANA
  995.          KS - KANSAS
  996.          KY - KENTUCKY
  997.          LA - LOUISIANA
  998.          MA - MASSACHUSETTES
  999.          MD - MARYLAND
  1000.          ME - MAINE
  1001.          MH - MARSHALL ISLANDS
  1002.          MI - MICHIGAN
  1003.          MN - MINNESOTA
  1004.          MO - MISSOURI
  1005.          MP - NORTHERN MARINIA ISLANDS
  1006.          MS - MISSISSIPPI
  1007.          MT - MONTANA
  1008.          NC - NORTH CAROLINA
  1009.          ND - NORTH DAKOTA
  1010.          NE - NEBRASKA
  1011.          NH - NEW HAMPSHIRE
  1012.          NJ - NEW JERSEY
  1013.          NM - NEW MEXICO
  1014.          NV - NEVADA
  1015.          NY - NEW YORK
  1016.          OH - OHIO
  1017.          OK - OKLAHOMA
  1018.          OR - OREGON
  1019.          PA - PENNSYLVANIA
  1020.          PR - PUERTO RICO
  1021.          PW - PALAU ISLANDS
  1022.          RI - RHODE ISLAND
  1023.          SC - SOUTH CAROLINA
  1024.          SD - SOUTH DAKOTA
  1025.          TN - TENNESSEE
  1026.          TX - TEXAS
  1027.          UT - UTAH
  1028.          VA - VIRGINIA
  1029.          VI - VIRGIN ISLANDS
  1030.          VT - VERMONT
  1031.          WA - WASHINGTON
  1032.          WI - WISCONSIN
  1033.          WV - WEST VIRGINIA
  1034.          WY - WYOMING
  1035.  
  1036.